<template>
  <div class="login-form">
    <el-card class="login-card">
      <el-breadcrumb>
        <el-breadcrumb-item :to="{ path: '/login' }">登录</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/register' }">注册</el-breadcrumb-item>
      </el-breadcrumb>
            <div style="margin: 20px 0;"></div>
      <el-form :model="form" :rules="rules" ref="loginForm" label-width="100px">
        <el-form-item label="邮箱" prop="email">
          <el-input type="text" v-model="form.email" placeholder="请输入邮箱">
            <app-svg-icon icon-class="email" slot="suffix"></app-svg-icon>
          </el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input type="password" v-model="form.password" placeholder="请输入密码">
            <app-svg-icon icon-class="password" slot="suffix"></app-svg-icon>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button>取消</el-button>
          <el-button @click="onSubmit('loginForm')" type="primary">登录</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { State } from "vuex-class";
@Component({})
export default class Login extends Vue {
  @State("direction") direction;
  form: any = { email: "", password: "" };
  rules: any = {
    email: [
      { required: true, message: "请输入邮箱", trigger: "blur" },
      { type: "email", message: "请输入正确邮箱", trigger: "blur" }
    ],
    password: [{ required: true, message: "请输入密码", trigger: "blur" }]
  };

  onSubmit(formName) {
    this.$refs[formName]["validate"](valid => {
      if (!valid) {
        return;
      } else {
        console.log(this.form);
      }
    });
  }
}
</script>

<style lang="scss">
.login-form {
  width: 400px;
  align-self: center;
  margin: 0 auto;
}
</style>

